package com.example.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.domain.BusType;
import com.example.service.BusTypeService;
import com.example.util.Results;
import com.example.domain.vo.BusNoteTypeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/notetype")
public class NoteTypeController {

    @Autowired
    private BusTypeService busTypeService;

    @PostMapping("/saveorupdate")
    public JSONObject noteSaveOrUpdateController(@RequestBody @Validated BusNoteTypeVo vo){
        busTypeService.saveOrUpdateBusType(vo);
        return Results.success("操作成功");
    }

    @GetMapping("/getone")
    public JSONObject getOneController(@RequestParam("id")String id){
        BusType busType=busTypeService.getOneById(id);
        return Results.success(busType);
    }

    @GetMapping("/getlist/userId")
    public JSONObject getnoteTypeListController(@RequestParam("userId")String userId){
        List<BusType> busTypeList=busTypeService.getListByUserId(userId);
        return Results.success(busTypeList);
    }
}
